package com.balachat.mcpserver.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Service;

@Service
public class OpenMeteoService {
    private Logger logger = LoggerFactory.getLogger(OpenMeteoService.class);

    @Tool(description = "根据经纬度获取天气预报")
    public String getWeatherForecast(@ToolParam(description = "维度,例如: 39.9402") String latitude,
                                     @ToolParam(description = "经度,例如: 116.4074") String longitude) {
        String response = "今日大风，温度3-15摄氏度";
        logger.info("根据经纬度获取天气预报 mcp client call parameter:  latitude = {}, longitude = {}", latitude, longitude);
        return "当前位置（纬度：" + latitude + "，经度：" + longitude + "）的天气信息：\n" + response;
    }

    @Tool(description = "根据经纬度获取空气质量信息")
    public String getAirQuality(@ToolParam(description = "维度,例如: 39.9402") String latitude,
                                @ToolParam(description = "经度,例如: 116.4074") String longitude) {
        logger.info("根据经纬度获取空气质量信息 mcp client call parameter: latitude = {}, longitude = {}", latitude, longitude);
        String response =  "- PM2.5: 15 μg/m³ (优)\n" +
                "- PM10: 28 μg/m³ (良)\n" +
                "- 空气质量指数(AQI): 21 (良)\n" +
                "- 主要污染物: 无";
        return "当前位置（纬度：" + latitude + "，经度：" + longitude + "）的空气质量信息：\n" + response;
    }
}
